# 图像融合：目标图像 = 图像1 * 系数1 + 图像2 * 系数2 + 亮度调节量

import cv2
import numpy as np
import matplotlib.pyplot as plt

# 读取图片
src1 = cv2.imread('src/lena.png')
src2 = cv2.imread('src/lena_gray.png')

# 1、图像融合
result = cv2.addWeighted(src1, 0.5, src2, 0.5, 10)

# 显示图像
cv2.imshow("src1", src1)
cv2.imshow("src2", src2)
cv2.imshow("result", result)

# 等待显示
cv2.waitKey(0)
cv2.destroyAllWindows()

# 2、图像类型转换- cvtColor()

# 彩色图像转灰度图像
result = cv2.cvtColor(src1, cv2.COLOR_BGR2GRAY)
# 显示图像
cv2.imshow("src", src1)
cv2.imshow("result", result)
# 等待显示
cv2.waitKey(0)
cv2.destroyAllWindows()

# BRG通道转RGB通道
result = cv2.cvtColor(src1, cv2.COLOR_BGR2RGB)
# 显示图像
cv2.imshow("src", src1)
cv2.imshow("result", result)
# 等待显示
cv2.waitKey(0)
cv2.destroyAllWindows()
